const Order = require('../models/order');

exports.add = function (req, res) {
	var _order = req.body;
	var order = new Order(_order);
	order.save(function(err, order) {
		if (err) {
			return res.status(403).json({msg: '添加失败，请重试', msg});
		}
		res.json({
			msg: '订单添加成功',
			order
		})
	})
}

exports.list = function (req, res) {
	Order.find({}, function(err, orders) {
		if (err) {
			return res.status(500).json({msg: '获取失败，请重试', err});
		}
		res.json({
			msg: '获取成功',
			orders
		})
	})
}
